#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
int istrue(int n, int i)
{
    int* arr = (int*)malloc(sizeof(int) * (n + 1));
    int count = 0;
    while (n)
    {
        int x = n % i;//1 4 0 2 0 2 1
        arr[count++] = x;
        n /= i;
    }
    for (int i = 0; i < count; i++)
    {
        if (arr[i] != arr[count - i - 1])
            return 0;
    }
    return 1;
}
bool isStrictlyPalindromic(int n) {
    for (int i = 2; i <= n - 2; i++)
    {
        if (istrue(n, i) == 0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int i = 0;
    scanf("%d", &i);
    bool ret = isStrictlyPalindromic(i);
    printf("%d", ret);
	return 0;
}